package com.ymatou.social.api.testcase;

import java.util.ArrayList;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.social.api.parameter.TagBean;
import com.ymatou.social.api.parameter.TagImageBean;
import com.ymatou.social.api.parameter.TagInfoBean;
import com.ymatou.social.api.parameter.UpdateNoteBean;
import com.ymatou.social.api.service.UpdateNoteCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AuthCallService;

/**
 * 修改日记接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_UpdateNote {
	private static UpdateNoteBean notebean;
	private static UpdateNoteCall notecall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("修改日记接口");
	}

	@Before
	public void caseUp() {
		notebean = new UpdateNoteBean();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(notecall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UpdateNote_001() {
		Logger.start(true,"修改日记成功");
		try {
			Integer sellerNewsId = 4545;
			String userName = "test007";
			// 登录app
			
			Map map2 =AuthCallService.authLogin(userName, "123456");
			String accessToken = (String) map2.get("AccessToken");
			notecall = new UpdateNoteCall(accessToken);
			String content = "auto test for update note";
			String position = "shanghai";
			Integer userId = 1113;
			Integer orderId = 105301809;
			String imei = null;
			String idfa = "idfa";
			String ckid = "cookies";
			String ip = "10.10.114.100";
			String os = "ios";
			String osVer = "8.4.1";
			String activityId = null;
			String activityName = null;
			Integer noteSource = 1;
			// 图片集合
			ArrayList<TagImageBean> tagImages = new ArrayList<TagImageBean>();
			// 图片信息
			TagImageBean tagimage = new TagImageBean();
			String pic = "E:/workspace/source/YMTTest/resource/Penguins.jpg";
			// 图片tagbean
			TagInfoBean tagInfo = new TagInfoBean();
			Integer xPoint = 45;
			Integer yPoint = 78;
			Integer imageTagStyle = 12;
			// tag list
			ArrayList<TagBean> tags = new ArrayList<TagBean>();
			// tag bean
			TagBean tag = new TagBean();
			Integer tagValId = 1;
			String tagVal = "bag";
			Integer imageTagType = 1;
			tag.setTagValId(tagValId);
			tag.setTagVal(tagVal);
			tag.setImageTagType(imageTagType);
			// 将tag bean加到 tag list
			tags.add(tag);
			tagInfo.setXPoint(xPoint);
			tagInfo.setYPoint(yPoint);
			tagInfo.setImageTagStyle(imageTagStyle);
			tagInfo.setTagInfos(tags);

			tagimage.setTagInfo(tagInfo);
			tagImages.add(tagimage);
			notebean.setSellerNewsId(sellerNewsId);
			notebean.setUserName(userName);
			notebean.setContent(content);
			notebean.setPosition(position);
			notebean.setUserId(userId);
			notebean.setOrderId(orderId);
			notebean.setImei(imei);
			notebean.setIdfa(idfa);
			notebean.setCkId(ckid);
			notebean.setIp(ip);
			notebean.setOs(os);
			notebean.setOsVer(osVer);
			notebean.setActivityId(activityId);
			notebean.setActivityName(activityName);
			notebean.setNoteSource(noteSource);
			notebean.setTagImages(tagImages);
			notecall.setData(notebean);
			// call
			notecall.callService();
			Logger.comment("社区修改日记 call" + notecall.getEntityString());
			Logger.comment("社区修改日记 response" + notecall.getReturnData());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}